package by.siarhei.java.tij.reusing.exercises.ex01;

/**
 * @author Siarhei Shchahratsou <s.siarhei@gmail.com>
 * @since 09.03.14
 */
public class SimpleClass {
}

class SecondClass {
    private SimpleClass simpleClass;

    public void print() {
        System.out.println("simpleClass == " + simpleClass);
    }

    public SimpleClass getSimpleClass() {
        if (simpleClass == null) {
            simpleClass = new SimpleClass();
        }
        return simpleClass;
    }

    public static void main(String[] args) {
        SecondClass secondClass = new SecondClass();
        secondClass.print();

        //lazy init
        secondClass.getSimpleClass();
        secondClass.print();
    }
}
